/**
 * 
 */
package main;

import org.apache.commons.math3.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math3.geometry.euclidean.twod.Vector2D;

import tools.CalculatePathLengthNormalizedSmoothing;
import tools.CalculateSmoothing;
import tools.LinearEquationToolkit_v1;
import tools.UtilFunctions;
import interfaces.IGetSmoothing;
import interfaces.ILinearEquation;

/**
 * @author Vivek
 *@version 0.01
 */
public class RunToolkit {

	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		
		/* For manually testing example : double xy[][] = {{1.2,.2,.3},{1.6,.3,.4},{1.8,.24,.38}};  
		 * 
		 * The equation formed :
		 *=====================
		 * Coefficient:
		 * Array2DRowRealMatrix{{1.0,1.2,1.44,1.7279999999999998,2.0736,2.4883199999999994},{1.0,2.4,4.32,6.911999999999999,10.367999999999999,0.0},{1.0,1.6,2.5600000000000005,4.096000000000001,6.553600000000001,10.485760000000003},{1.0,3.2,7.6800000000000015,16.384000000000004,32.76800000000001,0.0},{1.0,1.8,3.24,5.832000000000001,10.497600000000002,18.895680000000002},{1.0,3.6,9.72,23.328000000000003,52.488000000000014,0.0}}
		 * Constant:
		 * {0.2; 0.3; 0.3; 0.4; 0.24; 0.38}
		 * Solution:
		 * {36.93; -100.43; 101.36; -44.72; 7.3; -0.01}
		 * 
		 * Webpage used for testing the solution values: http://www.idomaths.com/simeq.php
		 */
//		double xy[][] = {{1.2,.2,.3},{1.6,.3,.4},{1.8,.24,.38}};  
//		double xy[][] = {{1.2,.2,.3,.025,.4},{1.6,.3,.4,.03,1.2},{1.8,.24,.38,.6,2.4}};  
//		double xy[][] = {{1,.2,.3,.24},{2,.6,.9,.7},{3,.3,.4,.5},{4,.7,.854,.234}};
//		double xy[][] = {{1,1,1},{2,2,2},{3,3,3},{4,4,4}};
//		double xy[][] = {{1,.3},{1.23,.54322},{2.2,.7453},{3,.95654}};
		
//		IGetSmoothing iget = new CalculateSmoothing();
//				
//		ILinearEquation lEq = new LinearEquationToolkit_v1();
//		
//		lEq.createEquations(xy);
////		((LinearEquationToolkit_v1) lEq).displayPoly();
//		lEq.solveEquation();	
////		lEq.displayEquation();	
//		
//		PolynomialFunction pfa = new PolynomialFunction(((LinearEquationToolkit_v1) lEq).solution.toArray());
//		System.out.println("passVlaues="+iget.getSmoothnessValue(lEq.getPredicted(2)));
//		System.out.println(UtilFunctions.display2DArray(lEq.getPredicted(2)));
//
//		
//		System.out.println("Call the new smoothing algorithm");
//		
//		CalculatePathLengthNormalizedSmoothing cplns = new CalculatePathLengthNormalizedSmoothing();
//		
//		System.out.println(cplns.getAlgorithmName());
//		
//		System.out.println(cplns.getSmoothnessValue(xy));
//		
////		UtilFunctions.displayArray(lEq.getIntermediatePoints(1,2,4),"Total predicted ");
		
		
//		double[][] xy = {{0.4,0.8048109424227088},{0.8,0.8170007999968066},{1.2000000000000002,0.8171502630972304},{1.6,0.0}};
//		double[][] xy1 = {{0.4,0.8048109424227088},{0.8,0.8170007999968066},{1.2000000000000002,0.8168512421064975},{1.6,0.0}};
//		result good
		
//		double[][] xy = {{0.4,0.8278175951967235},{0.8,0.8345013929719438},{1.2000000000000002,0.8346394555963983},{1.6,0.0}};
//		double[][] xy1 ={{0.4,0.8278175951967235},{0.8,0.8345013929719438},{1.2000000000000002,0.8343632379523105},{1.6,0.0}};
//		result good
		
//		double[][] xy = {{0.4,0.999999999999521},{0.8,0.9999999999995153},{1.2000000000000002,0.9999999999995157},{1.6,0.0}};
//		double[][] xy1 ={{0.4,0.999999999999521},{0.8,0.9999999999995153},{1.2000000000000002,0.9999999999995146},{1.6,0.0}};
//		RESULT good

//		double[][] xy = {{0.4,0.999999999999521},{0.8,0.9999999999995153},{1.2000000000000002,0.9999999999995157},{1.6,0.0}};
//		double[][] xy1 ={{0.4,0.999999999999521},{0.8,0.9999999999995153},{1.2000000000000002,0.9999999999995146},{1.6,0.0}};
//		result good

		double[][] xy = {{0.4,0.9999999999995179},{0.8,0.9999999999995137},{1.2000000000000002,0.9999999999995144},{1.6,0.0}};
		double[][] xy1 ={{0.4,0.9999999999995179},{0.8,0.9999999999995137},{1.2000000000000002,0.9999999999995133},{1.6,0.0}};
//		result good		
		
//		CalculatePathLengthNormalizedSmoothing cmps = new CalculatePathLengthNormalizedSmoothing();
//		
//		cmps.setup(xy);
//		System.out.println(cmps.sumAnglesSegmentLength());
//		
//		cmps.setup(xy1);
//		System.out.println(cmps.sumAnglesSegmentLength());
//		
		CalculateSmoothing cs = new CalculateSmoothing();
		
		System.out.println("Smoothing value:"+cs.getSmoothnessValue(xy));
		System.out.println("Smoothing value:"+cs.getSmoothnessValue(xy1));
		
		
		System.out.println("=======================");
		PathLengthNormalisedSmoothing plns = new PathLengthNormalisedSmoothing(xy);
//		System.out.println("Slope1:"+plns.slope(plns.lines[0]));
//		System.out.println("Slope2:"+plns.slope(plns.lines[1]));
		
		System.out.println("Smoothing value:"+plns.calculateSmoothness());
		
		PathLengthNormalisedSmoothing plns1 = new PathLengthNormalisedSmoothing(xy1);		
//		System.out.println("Slope1:"+plns.slope(plns1.lines[0]));
//		System.out.println("Slope2:"+plns.slope(plns1.lines[1]));
		
		System.out.println("Smoothing value:"+plns1.calculateSmoothness());
	}		

}
